package com.ymatou.iapi.usersafe.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.usersafe.parameter.GetDualSecurityResultRequestDtoBean;
import com.ymatou.iapi.usersafe.service.GetDualSecurityResultRequestDtoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AuthCallServiceV2;
import com.ymttest.database.sqlwapper.UserSafeWapper;
/**
*查询用户是否设置了双重验证
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetDualSecurityResultRequestDto{
	private static GetDualSecurityResultRequestDtoBean getdualsecurityresultrequestdtoBean;
	private static GetDualSecurityResultRequestDtoCall getdualsecurityresultrequestdtoCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询用户是否设置了双重验证");
	}

	@Before
	public void caseUp() {
		getdualsecurityresultrequestdtoBean=new GetDualSecurityResultRequestDtoBean();
		getdualsecurityresultrequestdtoCall=new GetDualSecurityResultRequestDtoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getdualsecurityresultrequestdtoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetDualSecurityResultRequestDto_001() {
		Logger.start(true,"查询用户是否设置了双重验证成功");
		try {
			int userid=1;
			AuthCallServiceV2.setSecurityQuestion(userid);
			AuthCallServiceV2.setSecurity(userid, true);
			getdualsecurityresultrequestdtoBean.setUserId(userid);
			getdualsecurityresultrequestdtoCall.setData(getdualsecurityresultrequestdtoBean);
			getdualsecurityresultrequestdtoCall.callService();			
			Logger.verifyEquals("true", getdualsecurityresultrequestdtoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("true", getdualsecurityresultrequestdtoCall.getString("Result"), "验证Result");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetDualSecurityResultRequestDto_002() {
		Logger.start(true,"不输入usreid，失败");
		try {
			getdualsecurityresultrequestdtoCall.setData(getdualsecurityresultrequestdtoBean);
			getdualsecurityresultrequestdtoCall.callService();			
			Logger.verifyEquals("false", getdualsecurityresultrequestdtoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("100", getdualsecurityresultrequestdtoCall.getString("ErrorCode"), "验证ErrorCode");
			Logger.verifyEquals("用户ID非法", getdualsecurityresultrequestdtoCall.getString("LastErrorMessage"), "验证LastErrorMessage");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetDualSecurityResultRequestDto_003() {
		Logger.start(true,"查询用户是否设置了双重验证false成功");
		try {
			int userid=3383;
			AuthCallServiceV2.setSecurity(userid, false);
			getdualsecurityresultrequestdtoBean.setUserId(userid);
			getdualsecurityresultrequestdtoCall.setData(getdualsecurityresultrequestdtoBean);
			getdualsecurityresultrequestdtoCall.callService();			
			Logger.verifyEquals("true", getdualsecurityresultrequestdtoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("false", getdualsecurityresultrequestdtoCall.getString("Result"), "验证Result");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetDualSecurityResultRequestDto_004() {
		Logger.start(false,"错误的userid失败");
		try {
			int userid=-100;
			getdualsecurityresultrequestdtoBean.setUserId(userid);
			getdualsecurityresultrequestdtoCall.setData(getdualsecurityresultrequestdtoBean);
			getdualsecurityresultrequestdtoCall.callService();			
			Logger.verifyEquals("false", getdualsecurityresultrequestdtoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("100", getdualsecurityresultrequestdtoCall.getString("ErrorCode"), "验证ErrorCode");
			Logger.verifyEquals("用户ID非法", getdualsecurityresultrequestdtoCall.getString("LastErrorMessage"), "验证LastErrorMessage");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetDualSecurityResultRequestDto_005() {
		Logger.start(true,"查询用户未设置过,失败");
		try {
			int userid=10;
			UserSafeWapper usw = new UserSafeWapper();
			usw.deleteUserdualsecurity(userid);
			getdualsecurityresultrequestdtoBean.setUserId(userid);
			getdualsecurityresultrequestdtoCall.setData(getdualsecurityresultrequestdtoBean);
			getdualsecurityresultrequestdtoCall.callService();			
			Logger.verifyEquals("true", getdualsecurityresultrequestdtoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("false", getdualsecurityresultrequestdtoCall.getString("Result"), "验证Result");
			Logger.verifyEquals("200", getdualsecurityresultrequestdtoCall.getString("ErrorCode"), "验证ErrorCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}